package labox.innovation.gameserver.network.clientpackets;

import labox.innovation.gameserver.model.FuzeTrusteeInstance;
import labox.innovation.gameserver.model.actor.instance.FuzePcInstance;

public final class AutoPkSetState extends L2GameClientPacket {
	
	private int  autoAttackState;	//自动攻击状态 0关闭自动攻击 1开启

	@Override
	public String getType() {
		
		return null;
	}

	@Override
	protected void readImpl() {
		
		autoAttackState=readByte();	//自动攻击状态 0关闭自动攻击 1开启
	}

	@Override
	protected void runImpl() {

		FuzePcInstance active = getClient().getActiveChar();
		if (active == null) {
			return;
		}

		if(autoAttackState==0 && active.isAutoAttack==true)
		{
			active.isAutoAttack = false;		//取消自动战斗
			FuzeTrusteeInstance trustee=active.getAI().getTrustee();
			if(trustee.getOffPickFilter()==0)
				active.getAI().onExit();
		}

		active.isAutoAttack = autoAttackState == 0?false:true;	//设置自动战斗
		if(active.isAutoAttack)								
		{
			active.getAI().onStart();		//过滤物品
		}
		
	}

	
}
